<template>
  <el-row style="width:100%">
    <el-col :span="18">
      <i class="el-icon-s-home"></i>
      <span>{{ item.name }}</span>
    </el-col>
    <el-col :span="6" class="right">
      <span>{{ item.manager }}</span>
      <el-dropdown @command="myCommand">
        <span class="el-dropdown-link">
          操作<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="add">添加子部门</el-dropdown-item>
          <el-dropdown-item v-if="!item.isSHow" command="edit"
            >查看部门</el-dropdown-item
          >
          <el-dropdown-item v-if="!item.isSHow" command="delet"
            >删除部门</el-dropdown-item
          >
        </el-dropdown-menu>
      </el-dropdown>
    </el-col>
  </el-row>
</template>

<script>
import { deletApi } from '@/api/departments'
export default {
  props: ['item'],
  methods: {
    async myCommand (command) {
      // console.log(1111)
      if (command == 'add') {
        this.$emit('addShow', this.item.id)
      } else if (command == 'edit') {
        this.$emit('editShow', this.item.id)
      } else if (command == 'delet') {
        await this.$confirm('是否删除')
        let res = await deletApi(this.item.id)
        this.$emit('deletAPI')
        // console.log(res)
      }
    }
  }
}
</script>

<style></style>
